
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.util.Arrays" %>
<%@include file="/public.jsp"%>
<%--
  Created by IntelliJ IDEA.
  User: Yzk20
  Date: 2025/6/24
  Time: 8:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>Title</title>
  <link rel="stylesheet" type="text/css" href="css/styless.css">
</head>
<body >
<%--&lt;%&ndash;style="background-image: url('/images/2.jpg');"&ndash;%&gt;导入背景图片--%>
<nav class="navbar">
  <ul class="nav-list">
    <li><a href="index.jsp" class="nav-link">首页</a></li>
    <li><a href="about.jsp" class="nav-link">关于我们</a></li>
    <%
      if (session.getAttribute("login_account") != null){ %>
    <li><a href="book1.jsp" class="nav-link">图书列表</a></li>
    <li><a href="profile.jsp" class="nav-link">借阅信息</a></li>
    <li><a href="userxx.jsp" class="nav-link">我的账户</a></li>
    <li><a href="quit.jsp" class="nav-link">登出</a></li>
    <% } else { %>
    <!-- 否则显示登录和注册链接 -->
    <li><a href="login.jsp" class="nav-link">登录</a></li>
    <li><a href="register.jsp" class="nav-link">注册</a></li>
    <li><a href="book1.jsp" class="nav-link">图书列表</a></li>
    <% } %>
  </ul>
</nav>
<form>
  <%
//    String readername=request.getParameter("readername");
//    Statement stmt=conn.createStatement();
//    String sql="SELECT * FROM borrowings t WHERE " +" 1=1 ";
//    if(null!=readername){
//      sql=sql+" AND  t.readername LIKE '%"+readername+"%' ";
//    }
//
//    ResultSet rs=stmt.executeQuery(sql);
    String login_account = (String) session.getAttribute("loginc");
    String sql =" SELECT * FROM Borrowings t WHERE 1=1 AND t.readername = ?";

    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, login_account);
    ResultSet rs = pstmt.executeQuery();


  %>
<%--  <table align="center" >--%>
<%--    <tr>--%>
<%--      <td>图书名称：<input type="text" name="bookName" id="bookName"></td>--%>
<%--    </tr>--%>
<%--    <tr>--%>
<%--      <td align="center" >--%>
<%--        <input type="hidden" name="actionType" value="book">--%>
<%--        <input type="submit" value="查询" >--%>
<%--        <input type="button" value="添加" onclick="book_add()">--%>
<%--      </td>--%>
<%--    </tr>--%>
<%--  </table>--%>
<%--  <hr>--%>
  <table align="center" width="80%" berder="1" >
    <h1 align="center">欢迎进入借阅信息</h1>
    <tr>
      <td>ID</td>
      <td>借阅人</td>
      <td>图书编号</td>
      <td>图书名称</td>
      <td>借阅时间</td>
      <td>预计归还时间</td>
      <td>借阅状态</td>
      <td>联系方式</td>
      <td>操作</td>

    </tr>
    <tbody id="devList">
    <tr>
        <%
    while(rs.next()) {
%>
    <tr>
      <td><%=rs.getString("Borrowingid")%></td>
      <td><%=rs.getString("readername")%></td>
      <td><%=rs.getString("bookid")%></td>
      <td><%=rs.getString("bookname")%></td>
      <td><%=rs.getString("Borrowingtime")%></td>
      <td><%=rs.getString("returntime")%></td>
      <td><%=rs.getString("status")%></td>
      <td><%=rs.getString("phone")%></td>
      <td>
        <input type="button" value="归还" onclick="returnDev(<%=rs.getString("Borrowingid")%>)">

      </td>
      <%}%>

    </tr>
    </tbody>
  </table>
</form>
<script>
<%--  function book_add(){--%>

<%--    window.location.href = "book/book_add.jsp"--%>
<%--  }--%>
function returnDev(Borrowingid) {
  window.location.href = "status.jsp?Borrowingid="+Borrowingid+"&status=已归还";
  alert("归还成功");
}

<%--  function book_delete(bookid){--%>
<%--    window.location.href = "book/book_delete.jsp?bookid="+ bookid;--%>
<%--  }--%>
</script>
</from>
</body>
</html>
